package com.my.hotel.mapper;

import com.my.hotel.entity.UserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRoleMapper {

    //删除用户关联的角色数据
    @Delete("delete from tb_user_role where user_id=#{userId}")
    public void delUserRole(int userId);

    @Insert("<script>" +
            "insert into tb_user_role values " +
            "<foreach collection=\"list\" item=\"ur\" separator=\",\"> " +
            "(null,#{ur.roleId},#{ur.userId})"+
            "</foreach>"+
            "</script>")
    public void addUserRole(List<UserRole> list);
}
